﻿using CPPEI.Coolzon.UI.Script;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace CPPEI.Coolzon.UI
{ 
    public partial class PartFrame
    {
        /// <summary>
        /// 缩放
        /// </summary>
        /// <param name="factor">0.1-2.0</param>
        /// <param name="pointInFrame"></param>
        public void API_Zoom(double factor, Point pointInFrame)
        {
            if (factor < 0.05d)
            {
                factor = 0.05d;
            }
            else if (factor > 2.0d)
            {
                factor = 2.0d;
            }

            if (factor != this.ZoomFactor)
            {
                Point pointInScene = this.TranslatePoint(pointInFrame, _scrollViewer);

                //double centerX = 1.0d;

                _scaleTransform.ScaleX = factor;
                _scaleTransform.ScaleY = factor;
                //Debug.WriteLine(string.Format("zoom:{0}", factor));
                double oldFactor = this.ZoomFactor;
                this.ZoomFactor = factor;

                if (Zoom != null)
                {
                    Zoom(oldFactor, this.ZoomFactor);
                }
            }
        }
    }
}
